#include "role.h"
#include "loc/loc-consts.h"
#include <cmath>

using namespace std;

bool Role::on_taxi() const { return (r4(ptr() + status_offset) >> 0x14) == 1; }

bool Role::combating() const {
  return (r4(ptr() + status_offset) >> 0x13) == 1;
}

float Role::dist(float x, float y, float z) const {
  float dx = this->x() - x;
  float dy = this->y() - y;
  float dz = this->z() - z;
  return sqrt(dx * dx + dy * dy + dz * dz);
}

float Role::dist_unit(const Role &other) const {
  float dx = x() - other.x();
  float dy = y() - other.y();
  float dz = z() - other.z();
  return sqrt(dx * dx + dy * dy + dz * dz);
}

float Role::x() const { return rfloat(ptr() + 0x130); }

float Role::y() const { return rfloat(ptr() + 0x134); }

float Role::z() const { return rfloat(ptr() + 0x138); }

float Role::h() const { return rfloat(ptr() + 0x140); }

float Role::v() const { return rfloat(ptr() + 0x144); }

uint32 Role::hp() const { return r4(ptr() + 0x119F8); }

uint32 Role::hp_max() const { return r4(ptr() + 0x11B38); }

uint32 Role::mp() const { return r4(ptr() + 0x11A00); }

uint32 Role::mp_max() const { return r4(ptr() + 0x11EB8); }

uint32 Role::level() const { return r4(ptr() + 0xD8 + 0x11B60); }

uint32 Role::casting() const { return r4(ptr() + 0x738); }

uint32 Role::channel() const { return r4(ptr() + 0x790); }

uint64 Role::tid1() const { return r8(ptr() + 0x11BF0); }

uint64 Role::tid2() const { return r8(ptr() + 0x11BF8); }

uintptr Role::ptr() const { return ptr_; }

Role::Role(uint64 ptr) : ptr_{ptr} {}

Role::~Role() {}
